<div class="special_box">
  <div class="special_box_top"></div>
  <div class="special_box_middle" style="min-height: 175px; height: 163px;">
  	<div style="padding: 7px 50px 0px 50px; *padding: 0px 50px;"><%= image_tag('peritor_theme/status_' + @deployment.status + '.gif', :title => @deployment.status) %></div>
      <div class="deployment_status">
        <b>Status:</b> <%=h @deployment.status %>
        <% if @deployment.cancelling_possible? %>
          &nbsp; &nbsp;
          <%= link_to "Cancel", cancel_project_stage_deployment_path(current_project, current_stage, @deployment), :confirm => "Are you sure? Killing this deployment will not cleanup and rollback.", :method => "post", :class => 'arrow_link' %>
        <% end %>
    	  <% if @deployment.completed? %>
          &nbsp; &nbsp;
      	  <%= link_to "Repeat", new_project_stage_deployment_path(current_project, current_stage) + '?repeat=' + h(@deployment.id), :class => 'arrow_link'  %>
        <% end %>
      </div>
  </div>
  <div class="special_box_bottom"></div>
</div>

<div class="box">
  <div class="box_top"></div>
  <div class="box_middle" style="height: 156px;">
	<p>
    <b>Task:</b>
	  <%=h @deployment.task %>
	</p>
	<p>
	  <b>Stage:</b>
	  <%= link_to @deployment.stage.name, project_stage_path(@project, @stage) %> 
	</p>
	<p>
	  <b>Deployed by:</b> 
	  <%= user_info(@deployment.user) rescue '' %>
	</p>
	<p>
	  <b>Revision:</b> 
	  <%= @deployment.revision %>
	</p>
	<p>
	  <b>Started:</b>
	  <%=h @deployment.created_at.to_s(:log) %> (<%=h current_user.time_zone rescue 'UTC' %>)
	</p>
  <p>
	  <b>Completed:</b>
	  <%=h "#{@deployment.completed_at.to_s(:log)} (#{current_user.time_zone})" rescue nil %>
	</p>
  </div>
  <div class="box_bottom"></div>
</div>

<div class="clear"></div>

<br />

<fieldset class="fieldset">
  <legend>Comment</legend>
  <%=web_friendly_text @deployment.description %>
</fieldset>
<br /> <br />

<fieldset class="fieldset">
  <legend>Log</legend>
  <div style="float:right; padding: 0px 5px 10px 0px; *padding: 0px"><input type="checkbox" class="noframe" id="auto_scroll_log" <%=h @auto_scroll ? 'checked="checked"' : ''%> > <label for="auto_scroll_log" class="redtext"><b>auto scroll</b></label></div>
	<div class="log_output">
		<pre><%=h @deployment.log.gsub('\n', "\n") rescue '' %></pre>
  </div>
</fieldset>

<% unless @deployment.completed? %>
  <script type="text/javascript">
    
    function update_status(){
      new Ajax.Updater('status_info','<%=h project_stage_deployment_path(@project, @stage, @deployment) %>.js',{
        method: 'get',
        evalScripts: true,
        parameters: {
          random_differentiator: Math.floor(Math.random()*50000), // work around IE caching bug
          auto_scroll: $('auto_scroll_log').checked
        }
      });
    }
    
    setTimeout(update_status, 3000);
    check_auto_scroll_log();
  </script>
<% end %>
